﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using Studio77.PopBall.Core;
using Studio77.PopBall.Util;

namespace Studio77.PopBall.Views
{
    public partial class MainPageItem : UserControl
    {
        public int Type { get; set; }

        public MainPageItem()
        {
            InitializeComponent();
        }

        public void SetType(int type)
        {
            this.StoryboardBling.Stop();
            if (type != 0 && type != 100)
            {
                this.ellipse.Visibility = System.Windows.Visibility.Visible;
                //this.StoryboardResume.Begin();
                Canvas.SetZIndex(this, 1);
                this.ellipse.Fill = ItemBrushSelector.GetBrush(type);
                Type = type;
            }
            else
            {
                this.ellipse.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        internal void Bling(double duration)
        {
            this.StoryboardBling.BeginTime = TimeSpan.FromMilliseconds(duration);
            this.StoryboardBling.Begin();
        }
    }
}
